export function getHouseList() {
  return request.get('/house/list')
}

export function getHouseImgById(id: number) {
  return request.get(`/houseImg/${id}`)
}

export function getHouseById(id: number) {
  return request.get(`/house/${id}`)
}

export function searchHouseByTitle(title: string, price?: any , stars?: any ) {
  if (price)
    return request.get(`/house/search?title=${title}&price=${price}`)
  if (stars)
    return request.get(`/house/search?title=${title}&stars=${stars}`)
  if (stars && price)
    return request.get(`/house/search?title=${title}&stars=${stars}&price=${price}`)

  return request.get(`/house/search?title=${title}`)
}

export function getHouseByCategoryId(id: number) {
  return request.get(`/house/cate/${id}`)
}

export function getReserveByUserId(userId: any) {
  return request.get(`/reserve/my/${userId}`)
}

export function getNoPayReserveByUserId(userId: any) {
  return request.get(`/reserve/order/${userId}`)
}

// batch
export function deleteReserve(ids: any) {
  return request.delete('/reserve/batch', {
    data: { ids },
  })
}

export function submitReserve(ids: any) {
  return request.put('/reserve/batch', {
    ids,
  })
}

export function reserveHouse(reserce: any) {
  return request.post('/reserve', {
    ...reserce,
  })
}
